package com.lywz.web.action.admin.city;

import java.util.Collection;

import com.lywz.biz.common.entity.city.CityTraffic;
import com.lywz.biz.common.enums.City;
import com.lywz.web.struts.GZAbstracterAction;


public class TrafficInfoAction extends GZAbstracterAction {
    
    private static final long serialVersionUID = -1215000009669109935L;
    
    final String CITY_TRAFFIC = "traffic";
    //数据库中自增产生的id
    private short id;


    //城市交通信息列表
    private Collection<CityTraffic> cityTrafficList;

    //城市交通信息
    private CityTraffic cityTraffic;

    //获得没有添加的其他城市的名称及id
    private Collection<City> otherCityList;
    
    /**************************** action方法 ***************************************/
    //显示所有城市的交通信息
    public String showTrafficInfoList() {
        cityTrafficList = cityInfoService.getCityTrafficList();
        return SUCCESS;
    }

    //显示添加城市交通信息
    public String toAddTrafficInfo() {
        otherCityList = cityInfoService.getUnaddedCity(CITY_TRAFFIC);
        return "toAdd";
    }

    //添加城市信息
    public String addTrafficInfo() {
        cityInfoService.addCityTraffic(cityTraffic);
        return SUCCESS;
    }

    //跳转至城市交通修改页面
    public String toModifyTrafficInfo() {
        cityTraffic = cityInfoService.getCityTrafficById(id);
        return "toModify";
    }

    //修改城市交通
    public String modifyTrafficInfo() {
        cityInfoService.modifyCityTraffic(cityTraffic);
        return SUCCESS;
    }
    
    /***************************** setter getter ************************************/

    public Collection<CityTraffic> getCityTrafficList() {
        return cityTrafficList;
    }

    public void setCityTrafficList(Collection<CityTraffic> cityTrafficList) {
        this.cityTrafficList = cityTrafficList;
    }
    

    public CityTraffic getCityTraffic() {
        return cityTraffic;
    }

    public void setCityTraffic(CityTraffic cityTraffic) {
        this.cityTraffic = cityTraffic;
    }
    public Collection<City> getOtherCityList() {
        return otherCityList;
    }

    public void setOtherCityList(Collection<City> otherCityList) {
        this.otherCityList = otherCityList;
    }
    
    
    public short getId() {
        return id;
    }
 
    public void setId(short id) {
        this.id = id;
    }
}
